package com.loong.loong.hik.service;

import cn.hutool.core.text.UnicodeUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.loong.loong.common.core.util.R;
import com.loong.loong.hik.entity.CdcAlarm;
import com.loong.loong.hik.entity.CdcDept;
import com.loong.loong.hik.entity.CdcDevice;
import com.loong.loong.hik.entity.CdcPeople;
import com.loong.loong.hik.entity.HikCdcEquioment;
import com.loong.loong.hik.entity.HikCdcUser;
import com.loong.loong.hik.property.request.cdc.Equioment;
import com.loong.loong.hik.property.request.cdc.People;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Component;

/**
 * 疾控中心
 * @author jinyiang
 * @date 2023/3/12 14:45
 */
@Component
public class HikCdcVService {

	private final String DEVSTATUS = "http://192.168.75.240/pmdb/rest/v1/get_dev_status";

	private final String ALARM = "";

	private final String key="0c24wuqopxlkilc81vpvd-er4jxhizreaox_g5n6x5bw";

	private final String preUrl="http://192.168.214.252:8080/api/v2";

	//更新人员
	private final String UPDATE_PEOPLE = preUrl+"/employee/update/?key="+key;

	//获取部门信息
	private final String GET_DEPT = preUrl+"/department/get/?key="+key;

	//获取人员
	private final String GET_PEOPLE = preUrl+"/employee/get/?key="+key;
	//删除人员
	private final String DELETE_PEOPLE = preUrl+"/employee/delete/?key="+key;

	//更新部门信息
	private final String UPDATE_DEPT = preUrl+"/department/update/?key="+key;
	//更新部门信息
	private final String DELETE_DEPT = preUrl+"/department/delete/?key="+key;
	//	获取设备信息
	private final String GET_DEVICE = preUrl+"/iclock/get/?key="+key;
	//更新设备信息
	private final String UPDATE_DEVICE = preUrl+"/iclock/get/?key="+key;
	//信息发布系统接口的token
	private final String informationToken = "abcd123";
	//信息发布系统接口
	private final String information = "http://192.168.210.230:6101/API.aspx?token="+informationToken;

//	@Resource
//	private CdcDeviceService cdcDeviceService;
//	@Resource
//	private CdcDeptService cdcDeptService;
//	@Resource
//	private CdcPeopleService cdcPeopleService;
//	@Resource
//	private HikCdcEquiomentService hikCdcEquiomentService;
//	@Resource
//	private HikCdcTerminalService hikCdcTerminalService;

	//	get_dev_status（获取所有设备通讯状态）
	public R<List<CdcDevice>> getDevStatus(){
		try {
			List<CdcDevice> list = new ArrayList<>();
			String s = HttpUtil.get(DEVSTATUS, 600000);
			if (StringUtils.isNotEmpty(s)){
				JSONObject outParm = JSONObject.parseObject(s);
				if (outParm!=null){
					JSONArray dev_status = outParm.getJSONArray("dev_status");
					if (dev_status!=null&&dev_status.size()>0){
						String s1 = dev_status.toJSONString();
						list = JSONObject.parseArray(s1, CdcDevice.class);
					}
				}
			}
			return R.ok(list);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}

	}
	public void test(){
		doStart();
	}

	/**
	 * 刷疾控中心接口数据
	 */
	private void doStart() {

//		CdcDept cdcDept = new CdcDept();
//		R<List<CdcDept>> dept = getDept(cdcDept);
//		if (dept.getCode()==0){
//			List<CdcDept> data = dept.getData();
//			if (data!=null&&data.size()>0){
//				cdcDeptService.saveOrUpdateBatch(data);
//			}
//		}

//		People people = new People();
//		R<List<CdcPeople>> people1 = getPeople(people);
//		if (people1.getCode()==0){
//			List<CdcPeople> data = people1.getData();
//			if (data!=null&&data.size()>0){
//				cdcPeopleService.saveOrUpdateBatch(data);
//			}
//		}

//		Equioment equioment = new Equioment();
//		R<List<HikCdcEquioment>> equioment1 = getEquioment(equioment);
//		if (equioment1.getCode()==0){
//			List<HikCdcEquioment> data1 = equioment1.getData();
//			if (data1!=null&&data1.size()>0){
//				hikCdcEquiomentService.saveOrUpdateBatch(data1);
//			}
//		}
//		String s = "{\n" +
//				"\"code\": 0,\n" +
//				"\"msg\": \"成功\",\n" +
//				"\"data\": [\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B5D9\",\n" +
//				"\"name\": \"培训楼6F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B5C3\",\n" +
//				"\"name\": \"培训楼7F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B58B\",\n" +
//				"\"name\": \"实验楼2F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B553\",\n" +
//				"\"name\": \"动物楼1F\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B568\",\n" +
//				"\"name\": \"动物楼2F\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B564\",\n" +
//				"\"name\": \"动物楼4F\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B5E7\",\n" +
//				"\"name\": \"实验楼1F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B760\",\n" +
//				"\"name\": \"实验楼3F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B589\",\n" +
//				"\"name\": \"实验楼3F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B577\",\n" +
//				"\"name\": \"实验楼1F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B5E6\",\n" +
//				"\"name\": \"实验楼2F副1\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B556\",\n" +
//				"\"name\": \"实验楼2F副2\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B546\",\n" +
//				"\"name\": \"实验楼4F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B555\",\n" +
//				"\"name\": \"实验楼4F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B5C5\",\n" +
//				"\"name\": \"实验楼5F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B7CA\",\n" +
//				"\"name\": \"实验楼5F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B748\",\n" +
//				"\"name\": \"实验楼6F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B768\",\n" +
//				"\"name\": \"实验楼6F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B765\",\n" +
//				"\"name\": \"实验楼7F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B661\",\n" +
//				"\"name\": \"实验楼7F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B5BF\",\n" +
//				"\"name\": \"实验楼8F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B563\",\n" +
//				"\"name\": \"实验楼8F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B521\",\n" +
//				"\"name\": \"实验楼9F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B615\",\n" +
//				"\"name\": \"实验楼9F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B767\",\n" +
//				"\"name\": \"实验楼10F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B550\",\n" +
//				"\"name\": \"实验楼11F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B576\",\n" +
//				"\"name\": \"实验楼10F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B52F\",\n" +
//				"\"name\": \"实验楼11F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B52B\",\n" +
//				"\"name\": \"培训楼2F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B579\",\n" +
//				"\"name\": \"培训楼2F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B7FD\",\n" +
//				"\"name\": \"培训楼3F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B584\",\n" +
//				"\"name\": \"培训楼3F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B4F1\",\n" +
//				"\"name\": \"培训楼4F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B617\",\n" +
//				"\"name\": \"培训楼5F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B538\",\n" +
//				"\"name\": \"培训楼5F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B5C6\",\n" +
//				"\"name\": \"培训楼6F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B574\",\n" +
//				"\"name\": \"培训楼7F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B625\",\n" +
//				"\"name\": \"培训楼8F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B518\",\n" +
//				"\"name\": \"动物楼3F\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B660\",\n" +
//				"\"name\": \"培训楼1F副1\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B616\",\n" +
//				"\"name\": \"培训楼1F主\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B56B\",\n" +
//				"\"name\": \"培训楼3F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B588\",\n" +
//				"\"name\": \"培训楼2F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B548\",\n" +
//				"\"name\": \"培训楼1F副2\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B59C\",\n" +
//				"\"name\": \"培训楼8F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"},\n" +
//				"{\n" +
//				"\"id\": \"D05F64D2B5DE\",\n" +
//				"\"name\": \"培训楼4F副\",\n" +
//				"\"isOnline\": 0\n" +
//				"}\n" +
//				"]\n" +
//				"}\n";
//		JSONObject outParm = JSONObject.parseObject(s);
//		JSONArray data = outParm.getJSONArray("data");
//		String s1 = data.toJSONString();
//		List<HikCdcTerminal> hikCdcTerminals = JSONObject.parseArray(s1, HikCdcTerminal.class);
//		hikCdcTerminalService.saveOrUpdateBatch(hikCdcTerminals);

	}

	// alarm (告警数据推送)
	public R<T> putAlarm(CdcAlarm cdcAlarm){
		try {

			String s = HttpRequest.put(ALARM).timeout(60000).body(cdcAlarm.toString()).execute().body();
			if (StringUtils.isNotEmpty(s)){
				JSONObject outParm = JSONObject.parseObject(s);
				if (outParm!=null){
					JSONArray dev_status = outParm.getJSONArray("dev_status");
					if (dev_status!=null&&dev_status.size()>0){
						String s1 = dev_status.toJSONString();
//						list = JSONObject.parseArray(s1, CdcDevice.class);
					}
				}
			}
			return R.ok();
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}
	}

	/**
	 * 获取部门信息
	 * @return
	 */
	public R<List<CdcDept>> getDept(CdcDept cdcDept){
		try {
			List<CdcDept> list = new ArrayList<>();
			Map<String, Object> map = new HashMap<>();
			String s = HttpUtil.post(GET_DEPT,map);
			if (StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if (outParm!=null&&(outParm.getIntValue("ret")==0)){
					JSONObject data = outParm.getJSONObject("data");
					if (data!=null){
						JSONArray items = data.getJSONArray("items");
						if (items!=null&&items.size()>0){
							String s1 = items.toJSONString();
							list = JSONObject.parseArray(s1, CdcDept.class);
						}
					}

				}
			}
			return R.ok(list);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}

	}


	/**
	 * 获取人员信息
	 * @return
	 */
	public R<List<CdcPeople>> getPeople(People people){
		try {
			List<CdcPeople> list = new ArrayList<>();
			Map<String, Object> map = new HashMap<>();
			String s = HttpUtil.post(GET_PEOPLE,map);
			if (StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if (outParm!=null&&(outParm.getIntValue("ret")==0)){
					JSONObject data = outParm.getJSONObject("data");
					if (data!=null){
						JSONArray items = data.getJSONArray("items");
						if (items!=null&&items.size()>0){
							String s1 = items.toJSONString();
							list = JSONObject.parseArray(s1, CdcPeople.class);
						}

					}
				}
			}
			return R.ok(list);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}

	}

	/**
	 * 更新部门信息
	 * @return
	 */
	public R updateDept(CdcDept cdcDept){
		try{
			String msg = "";
			List<Object> list = new ArrayList<>();
			list.add(cdcDept);
			String s = HttpUtil.post(UPDATE_DEPT,JSON.toJSONString(list), 600000);
			if(StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if(outParm!=null){
					msg =outParm.getString("msg");
					if (outParm.getIntValue("ret")==0){
						return R.ok(msg);
					}
				}
			}
			return R.failed(msg);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}
	}
	/**
	 * 删除部门信息
	 * @return
	 */
	public R deleteDept(CdcDept cdcDept){
		try{
			String msg = "";
			String s = HttpUtil.post(DELETE_DEPT,JSON.toJSONString(cdcDept), 600000);
			if(StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if(outParm!=null){
					msg =outParm.getString("msg");
					if (outParm.getIntValue("ret")==0){
						return R.ok(msg);
					}
				}
			}
			return R.failed(msg);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}
	}

	/**
	 * 更新人员信息
	 * @return
	 */
	public R updatePeople(CdcPeople cdcPeople){
		try{
			String msg = "";
			JSONObject object = new JSONObject();
			if (StringUtils.isNotEmpty(cdcPeople.getPin())){
				object.put("pin",cdcPeople.getPin());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getName())){
				object.put("name",cdcPeople.getName());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getHumidity())){
				object.put("humidity",cdcPeople.getHumidity());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getHumidity())){
				object.put("humidity",cdcPeople.getHumidity());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getDeptnumber())){
				object.put("deptnumber",cdcPeople.getDeptnumber());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getTelephone())){
				object.put("telephone",cdcPeople.getTelephone());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getMobile())){
				object.put("mobile",cdcPeople.getMobile());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getGender())){
				object.put("gender",cdcPeople.getGender());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getEmail())){
				object.put("email",cdcPeople.getEmail());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getIdentitycard())){
				object.put("identitycard",cdcPeople.getIdentitycard());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getCardno())){
				object.put("cardno",cdcPeople.getCardno());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getPosition())){
				object.put("position",cdcPeople.getPosition());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getZonecode())){
				object.put("zonecode",cdcPeople.getZonecode());
			}
			if (cdcPeople.getBirthday()!=null){
				object.put("birthday",cdcPeople.getBirthday());
			}
			if (cdcPeople.getHiredday()!=null){
				object.put("hiredday",cdcPeople.getHiredday());
			}
			if (cdcPeople.getTrialstarttime()!=null){
				object.put("trialstarttime",cdcPeople.getTrialstarttime());
			}
			if (cdcPeople.getTrialendtime()!=null){
				object.put("trialendtime",cdcPeople.getTrialendtime());
			}
			if (cdcPeople.getContractstarttime()!=null){
				object.put("contractstarttime",cdcPeople.getContractstarttime());
			}
			if (cdcPeople.getEducational()!=null){
				object.put("educational",cdcPeople.getEducational());
			}
			if (cdcPeople.getInlate()!=null){
				object.put("inlate",cdcPeople.getInlate());
			}
			if (cdcPeople.getOutearly()!=null){
				object.put("outearly",cdcPeople.getOutearly());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getAddress())){
				object.put("address",cdcPeople.getAddress());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getNational())){
				object.put("national",cdcPeople.getNational());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getNational())){
				object.put("national",cdcPeople.getNational());
			}
			if (cdcPeople.getHiretype()!=null){
				object.put("hiretype",cdcPeople.getHiretype());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getSelfpassword())){
				object.put("selfpassword",cdcPeople.getSelfpassword());
			}
			if (cdcPeople.getAtt()!=null){
				object.put("att",cdcPeople.getAtt());
			}
			if (cdcPeople.getComverifys()!=null){
				object.put("comverifys",cdcPeople.getComverifys());
			}
			if (StringUtils.isNotEmpty(cdcPeople.getEnrollpic())){
				object.put("enrollpic",cdcPeople.getEnrollpic());
			}

			List<Object> list = new ArrayList<>();
			list.add(object);
			String s = HttpUtil.post(UPDATE_PEOPLE, JSONObject.toJSONString(list), 600000);
			if(StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if(outParm!=null){
					msg =outParm.getString("msg");
					if (outParm.getIntValue("ret")==0){
						return R.ok(msg);
					}
				}
			}
			return R.failed(msg);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}
	}
	/**
	 * 删除人员信息
	 * @return
	 */
	public R deletePeople(CdcPeople cdcPeople){
		try{
			String msg = "";
			JSONObject object = new JSONObject();
			if (StringUtils.isNotEmpty(cdcPeople.getPin())){
				object.put("pin",cdcPeople.getPin());
			}
			String s = HttpUtil.post(DELETE_PEOPLE, JSONObject.toJSONString(object), 600000);
			if(StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if(outParm!=null){
					msg =outParm.getString("msg");
					if (outParm.getIntValue("ret")==0){
						return R.ok(msg);
					}
				}
			}
			return R.failed(msg);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}
	}
	/*获取设备信息*/
	public R<List<HikCdcEquioment>> getEquioment(Equioment equioment){
		try {
			List<HikCdcEquioment> list = new ArrayList<>();
			Map<String, Object> map = new HashMap<>();
			String s = HttpUtil.post(GET_DEVICE,map);
			if (StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if (outParm!=null&&(outParm.getIntValue("ret")==0)){
					JSONObject data = outParm.getJSONObject("data");
					if (data!=null){
						JSONArray items = data.getJSONArray("items");
						if (items!=null&&items.size()>0){
							String s1 = items.toJSONString();
							list = JSONObject.parseArray(s1, HikCdcEquioment.class);
						}

					}
				}
			}
			return R.ok(list);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}

	}
	/*更新设备信息*/
	public R updateEquioment(Equioment equioment){
		try{
			String msg = "";
			String s = HttpUtil.post(UPDATE_PEOPLE,equioment.toString(), 600000);
			if(StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if(outParm!=null){
					msg =outParm.getString("msg");
					if (outParm.getIntValue("ret")==0){
						return R.ok(msg);
					}
				}
			}
			return R.failed(msg);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}
	}
	/*添加用户*/
	public R insertUser(HikCdcUser hikCdcUser){
		try {
			String msg ="";
			Map<String, Object> map = new HashMap<>();
			map.put("service","user");
			map.put("method","add");
			map.put("data",hikCdcUser);
			String s = HttpUtil.post(information,map);
			if (StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if (outParm!=null&&(outParm.getIntValue("code")==0)){
					return R.ok("新增成功！");
				}
				msg = outParm.getString("msg");
			}
			return R.failed(msg);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}

	}

	/*修改用户*/
	public R updateUser(HikCdcUser hikCdcUser){
		try {
			String msg ="";
			Map<String, Object> map = new HashMap<>();
			map.put("service","user");
			map.put("method","modify");
			map.put("data",hikCdcUser);
			String s = HttpUtil.post(information,map);
			if (StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if (outParm!=null&&(outParm.getIntValue("code")==0)){
					return R.ok("修改成功！");
				}
				msg = outParm.getString("msg");
			}
			return R.failed(msg);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}

	}
	/*删除用户*/
	public R delUser(HikCdcUser hikCdcUser){
		try {
			String msg ="";
			Map<String, Object> map = new HashMap<>();
			map.put("service","user");
			map.put("method","removeByAccount");
			List<String> list = new ArrayList<>();
			list.add(hikCdcUser.getAccount());
			map.put("data",list);
			String s = HttpUtil.post(information,map);
			if (StringUtils.isNotEmpty(s)){
				s =UnicodeUtil.toString(s);
				JSONObject outParm = JSONObject.parseObject(s);
				if (outParm!=null&&(outParm.getIntValue("code")==0)){
					return R.ok("修改成功！");
				}
				msg = outParm.getString("msg");
			}
			return R.failed(msg);
		}catch (Exception e){
			e.printStackTrace();
			return R.failed("接口异常，异常原因是"+e.getMessage());
		}

	}

}
